import { Component, Inject, OnInit } from '@angular/core';
import { NZ_MODAL_DATA, NzModalRef } from 'ng-zorro-antd/modal';
import { ArrayService } from '@delon/util';

@Component({
	selector: 'app-custom-column',
	templateUrl: './custom-column.component.html',
	styleUrls: ['./custom-column.component.less'],
})
export class CustomColumnComponent implements OnInit {
	constructor(
		private nzModalRef: NzModalRef,
		@Inject(NZ_MODAL_DATA) public modalData: any[]
	) {}

	ngOnInit(): void {
	}

	close() {
		this.nzModalRef.close();
	}

	saveAndClose() {
		this.modalData.every((i) => {
			if (i.children) {
				i.checked = i.children.filter((i) => i.checked).length > 0;
			}
			return i;
		});
		this.nzModalRef.close(this.modalData);
	}
}
